<template>
    <div>
        <el-card>
        <el-button @click="goBack" style="margin-bottom:20px" type="info">返回</el-button>
        <!--查询条件start --111s-->
        <el-form :inline="true"
                 :model="query"
                 class="query-form"
                 size="small">
            <el-form-item class="query-form-item">
                <el-input v-model="query.searchtext"
                          placeholder="请输入商品名称"
                          prefix-icon="el-icon-search"
                          clearable></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary"
                           icon="el-icon-search"
                           @click="onSubmit">查询</el-button>
            </el-form-item>
        </el-form>
        <!--查询条件end-->
        <!--列表start --->
        <el-table ref="multipleTable"
                  v-loading="loading"
                  :data="list"
                  :header-cell-style="{background:'#F4F4F5',color:'#606266'}"
                  border>
            <el-table-column label="ID"
                             prop="commodityid"
                             width="80"
                             align="center" />
            <el-table-column label="图片"
                             prop="commodityicon"
                             align="center"
                             width="180">
                <template slot-scope="scope">
                    <el-popover v-if="scope.row.commodityicon"
                                placement="right"
                                trigger="hover">
                        <img :src="scope.row.commodityicon"
                             style="width:400px;border-radius:3px;">
                        <img slot="reference"
                             :src="scope.row.commodityicon"
                             style="max-height: 80px;max-width: 50px;border-radius:5px;">
                    </el-popover>
                    <span v-else>-</span>
                </template>
            </el-table-column>
            <el-table-column label="分类"
                             with="300"
                             prop="thirdcategoryname"
                             align="center">
            </el-table-column>
            <el-table-column label="商品名称"
                             with="300"
                             prop="commodityname"
                             align="center">
            </el-table-column>
            <el-table-column label="添加时间"
                             with="300"
                             :show-overflow-tooltip="true"
                             align="center">
                <template slot-scope="scope">
                    <i class="el-icon-time"
                       v-if="scope.row.createtime!=null"></i>
                    <span v-if="scope.row.createtime!=null">{{ scope.row.createtime | formatDateStr('yyyy-MM-dd hh:mm:ss') }}</span>
                    <span v-else>无</span>
                </template>
            </el-table-column>
            <el-table-column label="审核状态"
                             with="100"
                             prop="commoditystatus"
                             align="center">
                <template slot-scope="scope">
                    <span style="color:#ffa659;"      v-if="scope.row.commoditystatus ==0">审核中</span>
                    <span style="color:#4acf1e;" v-else-if="scope.row.commoditystatus ==1">已通过</span>
                    <span style="color:#dc0101;" v-else-if="scope.row.commoditystatus ==2">已驳回</span>
                </template>
            </el-table-column>
            <el-table-column label="操作"
                             align="center">
                <template slot-scope="scope">
                    <el-button type="primary"
                               size="mini"
                               @click.native="detailForm(scope.row)">查看
                    </el-button>
                </template>
            </el-table-column>
        </el-table>
        <!--列表end --222e-->


        <!--分页模块start-->
        <el-pagination class="pagination-container"
                       background
                       :page-size="query.pageSize"
                       @size-change="handleSizeChange"
                       @current-change="handleCurrentChange"
                       layout="total,sizes,prev, pager, next, jumper"
                       :current-page="query.currentPage"
                       :page-sizes="[10, 20, 30, 50]"
                       :total="totalNumber"></el-pagination>
        <!--分页模块end-->

        <el-dialog title="商品信息"
                   :visible.sync="dialogAddOrEdit"
                   width="50%"
                   :before-close="hideDialogAddOrEdit">
                   <el-card>
            <div class="commodityDetails">
                
                <el-row>
                    <el-col :span="12">
                        <span> 商品名称：</span> <span>{{commodityDetails.commodityname}}</span>
                    </el-col>
                    <el-col :span="12">
                        <span>审核状态：</span>
                        <span style="color:#ffa659;"      v-if="commodityDetails.commoditystatus ==0">审核中</span>
                        <span style="color:#4acf1e;" v-else-if="commodityDetails.commoditystatus ==1">已通过</span>
                        <span style="color:#dc0101;" v-else-if="commodityDetails.commoditystatus ==2">已驳回</span>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="24">
                        <span> 商品分类：</span> <span>{{commodityDetails.topcategoryname}},{{commodityDetails.secondarycategoryname}},{{commodityDetails.thirdcategoryname}}</span>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <span> 经销价：</span> <span>{{commodityDetails.commodityoldprice}}元</span>
                    </el-col>
                    <el-col :span="12">
                        <span> 零售价：</span> <span>{{commodityDetails.commodityprice}}元</span>
                    </el-col>
                </el-row>
                <!-- <el-row>
                    <el-col :span="12">
                        <span> 成本价：</span> <span>999元</span>
                    </el-col>
                    <el-col :span="12">
                        <span> 分销价：</span> <span>250元</span>
                    </el-col>
                </el-row> -->
                <!-- <el-row>
                    <el-col :span="12">
                        <span> 快递：</span> <span>{{commodityDetails.postagetype == 0 ? "包邮" : "不包邮"}}</span>
                    </el-col>
                    <el-col :span="12">
                        <span> 发货地：</span> <span>{{commodityDetails.commodityfrom}}</span>
                    </el-col>
                </el-row> -->
                <el-row>
                    <el-col :span="12">
                        <span> 添加时间：</span> <span>{{commodityDetails.createtime | formatDateStr('yyyy-MM-dd hh:mm:ss')}}</span>
                    </el-col>
                    <el-col :span="12">
                        <span> 商品ID：</span> <span>{{commodityDetails.commodityid}}</span>
                    </el-col>
                </el-row>
                <el-row>
                    <!-- <el-col :span="12">
                        <span> 商品评论：</span> <span>查看</span>
                    </el-col> -->
                    <el-col :span="12">
                        <span> 上架：</span> <span>已上架</span>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <span> 封面图：</span>
                        <el-popover
                           v-if="commodityDetails.commodityicon"
                            placement="right"
                            trigger="hover">
                            <img :src="commodityDetails.commodityicon"
                                 style="width:600px;border-radius:3px;">
                            <img  slot="reference"
                                  :src="commodityDetails.commodityicon"
                                  style="position: relative;top:13px;max-height: 80px;max-width: 100px;border-radius:5px;">
                        </el-popover>
                         <span v-else>-</span>
                    </el-col>
                    <el-col :span="12">
                        <!-- commoditynum -->
                        <span> 库存：</span> <span>{{commodityDetails.commoditynum}}</span>
                    </el-col>
                </el-row>
                <span v-if="attributecontenct.length !=0 && attributecontenct !=null">
                <h3 style="height: 50px; margin-left: 0px" class="thrTitle" >基本属性</h3>
                <el-form>
                <div :prop="'fieldname' + index" v-for="(item, index) in attributecontenct" :key="item.id">
                    <el-form-item label-width="180px" :label="item.fieldname + '：'">
                    <el-input
                        v-model.trim="formData1[item.fieldname]"
                        v-if="item.fieldtype == '文字'"
                        type="text"
                        :disabled="true"
                        maxlength="10"
                        :placeholder="'请填写' + item.fieldname"
                    ></el-input>
                    <el-input
                        v-model.trim="formData1[item.fieldname]"
                        v-if="item.fieldtype == '数字'"
                        :disabled="true"
                        type="number"
                        maxlength="10"
                        :placeholder="'请填写' + item.fieldname"
                    ></el-input>
                    
                    </el-form-item>
                </div>
                </el-form>
                </span>

                <span v-if="attributeextendcontenct.length !=0 && attributeextendcontenct !=null">
                <h3 style="height: 50px; margin-left: 0px" class="thrTitle"  >扩展属性</h3>
                <el-form>
                <div
                    :prop="'extendfieldname' + index"
                    v-for="(item, index) in attributeextendcontenct"
                    :key="item.id"
                >
                    <el-form-item
                    label-width="180px"
                    :label="item.extendfieldname + '：'"
                    >
                    <el-input
                        v-model.trim="formData1[item.extendfieldname]"
                        
                        v-if="item.fieldtype == '文字'"
                        :disabled="true"
                        type="text"
                        maxlength="10"
                        :placeholder="'请填写' + item.extendfieldname"
                    ></el-input>
                    <el-input
                        v-model.trim="formData1[item.extendfieldname]"
                        
                        v-if="item.fieldtype == '数字'"
                        :disabled="true"
                        type="number"
                        maxlength="10"
                        :placeholder="'请填写' + item.extendfieldname"
                    ></el-input>
                    
                    </el-form-item>
                </div>
                </el-form>
                </span>
                <span v-if="categoryTemplate != [] && categoryTemplate != null" >
                    <h3 class="thrTitle" style="margin-top:20px;margin-left:0;">{{categoryTemplate.name || ""}}</h3>
                <el-form>
                    <el-form-item :label="item.fieldname+'：'" label-width="180px" :prop="'fieldname'+index" v-for="(item,index) in categoryTemplate.templateItemFormList" :key="item.id">
                        <input type="hidden" v-model="item.fieldvalue">
                        <el-input v-model="formData4[item.fieldname]" @input="onInput()" @change="changeInput(item)" v-if="item.fieldtype == '文字'" type="text" :placeholder="'请填写'+item.fieldname" disabled></el-input>
                        <el-input v-model="formData4[item.fieldname]" @input="onInput()" @change="changeInput(item)" v-if="item.fieldtype == '数字'" type="number" :placeholder="'请填写'+item.fieldname" disabled></el-input>
                        <!--<el-upload
                            v-if="item.fieldtype == '图片'"
                            :action="uploadUrl"
                            :on-success="(response, file,fileList)=> handleFieldSuccess(response, file,fileList,'formData4','fieldname' + index,index)"
                            :on-remove="(file,fileList)=> handleFieldPicRemove(file, fileList,'formData4','fieldname' + index,index)"
                            :on-change="(file)=> handleChange(file)"
                            list-type="picture-card"
                            :show-file-list="false"
                            class="avatar-uploader"
                            disabled
                        >
                        <img v-if="item.fieldvalue" :src="item.fieldvalue" class="avatar">
                        <i v-else class="el-icon-plus"></i>
                        </el-upload>-->
                        <el-popover v-if="item.fieldtype == '图片'" placement="right" trigger="hover">
                            <img :src="item.fieldvalue" style="width:400px;border-radius:3px;">
                            <img slot="reference" :src="item.fieldvalue" style="max-height: 80px;max-width: 150px;border-radius:5px;">
                        </el-popover>
                    </el-form-item>
                </el-form>
            </span>
                <!--商品规格-->
                <el-table
                    ref="multipleTable"
                    v-loading="loading"
                    :data="parameterlist"
                    :header-cell-style="{background:'#F4F4F5',color:'#606266'}"
                    @selection-change="handleSelectionChange"
                    border
                >
                    <!--商品规格-->
                    <el-table-column label="商品图片" width="100"  align="center">
                        <template slot-scope="scope">
                            <el-popover v-if="scope.row.inventorypic" placement="right" trigger="hover">
                                <img :src="scope.row.inventorypic" style="width:400px;border-radius:3px;">
                                <img
                                    slot="reference"
                                    :src="scope.row.inventorypic"
                                    style="max-height: 80px;max-width: 50px;border-radius:5px;"
                                >
                            </el-popover>
                            <span v-else>-</span>
                        </template>
                    </el-table-column>
                    <el-table-column label="规格参数" align="center"  >
                        <el-table-column v-for="(item,index) in inputData" :key="index" :label='item.key' width="150" align="center">
                            <template slot-scope="scope">
                                <div v-if="scope.row.splist!==undefined">
                                    <el-select v-model="scope.row.splist[index]" placeholder="请选择" disabled  ref="sel" >
                                        <el-option
                                            v-for="(it,ind) in (item.val.split(','))"
                                            :key="ind"
                                            :label="it"
                                            :value="it">
                                        </el-option>
                                    </el-select>
                                </div>
                            </template>
                        </el-table-column>
                    </el-table-column>

                    <el-table-column label="成本价" prop="costprice"  align="center"/>
                    <el-table-column label="经销价" prop="secondaryagentprice"  align="center"/>
                    <el-table-column label="分销价" prop="commodityprice"  align="center"/>
                    <el-table-column label="零售价" prop="commodityoldprice" align="center"/>
                    <!--                <el-table-column label="代理价" prop="primaryagentprice"  align="center"/>-->
                    <el-table-column label="库存" prop="inventorynum"  align="center"/>

                </el-table>
                <el-row>
                    <el-col :span="24">
                        <span> 商品轮播：</span>
                    </el-col>
                    <el-col :offset="index?1:0" :span="5" v-for="(item,index) in commodityDetails.commoditypiclist" :key="index">
                        <el-popover
                            placement="right"
                            trigger="hover">
                            <img :src="item.picurl"
                                 style="width:600px;border-radius:3px;">
                            <img  slot="reference"
                                  :src="item.picurl"
                                  style="position: relative;top:13px;height: auto;width:100%;border-radius:5px;">
                        </el-popover>
                    </el-col>
                </el-row>
                <el-row  class="commodityDetailsBox">
                    <el-col :span="24">
                        <span> 商品详情：</span>
                    </el-col>
                    <div :span="24" v-html="commodityDetails.commoditydesc">
                    </div>
                </el-row>
            </div>
            </el-card>
            <span slot="footer"
                  class="dialog-footer">
        <el-button :disabled="commodityDetails.commoditystatus !=0" @click="examine(2)">驳 回</el-button>
        <el-button :disabled="commodityDetails.commoditystatus !=0" type="primary"
                   :loading="formSumbitLoding"
                   @click="examine(1)">审核通过</el-button>
        <el-button @click="dialogAddOrEdit = false">取消</el-button>
        </span>
        </el-dialog>


        <el-dialog title="请填写驳回原因" :visible.sync="dialogFormVisible"
                   width="50%"
                   top="5vh"
                   v-dialogDrag>
            <el-form >
                <el-form-item label="驳回原因：">
                    <el-input type="textarea"
                              style="width: 80%"
                              maxlength="300"
                              show-word-limit
                              :autosize="{ minRows: 4, maxRows: 10}"
                              v-model="rejectreason"></el-input>
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="dialogFormVisible = false">取 消</el-button>
                <el-button type="primary" @click="reject">确 定</el-button>
            </div>
        </el-dialog>
        </el-card>
    </div>
</template>
<script>
    import {
        merchantsCommodityList,
        merchantsCommodityToExamine
    } from "../../api/buscommodity/buscommodity";
    import { BASE_URL } from "../../config/app";
    /*用作表单的数据初始化*/
    const formJson = {
        topcategoryid: null,
        parentid: null, // bigint(20) not null auto_increment comment '分类ID',
        topcategoryname: "", // varchar(50) character set utf8 comment '分类名称',
        topcategorysort: 0, // smallint(6) default NULL comment '排序字段',
        topcategorypic: "", // varchar(300) character set utf8 comment '封面图',
        level: 2
    };
    export default {
        props: {
            getListQuery: Object
        },
        components: {},
        data() {
            return {
                dialogFormVisible: false,
                query: {
                    //查询条件
                    currentPage: 1,
                    pageSize: 10
                },
                formName: null,
                formMap: {
                    add: "添加",
                    edit: "编辑",
                    detail: "查看"
                },
                uploadUrl:BASE_URL + '/goldendays-currency/tool/uploadpro', //上传图片
                uploadData: [],
                category: [], //分类列表
                list: [], //列表集合
                totalNumber: 0, //分页总页数
                loading: true, //列表加载
                formSumbitLoding: false, //表单提交加载
                cancelToggle: false, //列表是否全选
                multipleSelection: [], //多选集合
                dialogAddOrEdit: false, //新增或编辑弹框开关
                dialogAddOrEditName: "", //新增或编辑弹框名字
                formData: formJson, //新增或修改的对象
                categoryTemplate: [], // 商品类目模板
                parameterlist: [], //add参数list
                inputData:[],//全部参数
                formData1:{},
                attributecontenct:[],//商品属性
                attributeextendcontenct:[],//商品属性模板
                formRules: {
                    commodityname: {
                        required: true,
                        message: "请输入名称",
                        trigger: "blur"
                    },
                    commodityprice: {
                        required: true,
                        message: "请输入售价",
                        trigger: "blur"
                    },
                    commodityoldprice: {
                        required: true,
                        message: "请输入代理价",
                        trigger: "blur"
                    },
                    commoditydesc: {
                        required: true,
                        message: "请输入商品详情",
                        trigger: "blur"
                    }
                },
                formData4: {
                    // 第四步表单
                    storename: null, // 店铺名称
                    enterinfoid: null, // 主键
                    certificationcontent: null, // 商品分类模板
                    topcategoryid: null, // 一级商品分类id
                    secondarycategoryid: null, // 二级商品分类id
                    categoryid: null // 三级商品分类id
                },
                commodityDetails: {},
                rejectreason: ""
            };
        },

        methods: {
            //图片上传成功
            handleFieldSuccess(response, file, fileList, index, key, item) {
                if (response.status === 1) {
                    this[index][key] = response.data;
                    if (item || item == 0) {
                        // item.fieldvalue = this.formData4[item.fieldname];
                        this.categoryTemplate.templateItemFormList[
                            item
                            ].fieldvalue = this.formData4[key];
                        console.log(
                            this.categoryTemplate.templateItemFormList[item]
                        );
                        console.log(this.formData4);
                    }
                    return;
                }
                this.$message.error("上传文件报错");
            },
            // 移除图片
            handleFieldPicRemove(file, fileList, index, key, item) {
                this[index][key] = null;
                if (item || item == 0) {
                    // item.fieldvalue = null;
                    this.categoryTemplate.templateItemFormList[
                        item
                        ].fieldvalue = null;
                    console.log(this.categoryTemplate.templateItemFormList[item]);
                    console.log(this.formData4);
                }
            },
            /*列表复选框选择事件*/
            handleSelectionChange(val) {
                this.multipleSelection = val;
                if (val == "") {
                    this.cancelToggle = false;
                    return;
                }
                this.cancelToggle = true;
            },
            handleFormDataSuccess(response, file, fileList, index, key, item) {
                if (response.status === 1) {
                    this[index][key] = response.data;
                    if (item) {
                        item.fieldvalue = this.formData4[item.fieldname];
                    }
                    return;
                }
                this.$message.error("上传文件报错");
            },
            // 强制刷新input
            onInput() {
                this.$forceUpdate();
            },
            // 模板input监听
            changeInput(val) {
                val.fieldvalue = this.formData4[val.fieldname];
                console.log(this.formData4);
            },
            handlePicRemove(file,fileList) {
                console.info("file=" + file+"fileList:"+fileList)
                console.info("commoditypiclist"+JSON.stringify(this.formData.commoditypiclist))
                var url = "";
                url = file.url;
                // alert(url)
                for (var i = 0; i < this.formData.commoditypiclist.length; i++) {
                    //alert(this.formData.commoditypiclist[i])
                    if (url===this.formData.commoditypiclist[i]){
                        this.formData.commoditypiclist.splice(i, 1);
                        console.info("commoditypiclist9999999999"+JSON.stringify(this.formData.commoditypiclist))
                    }
                }
                for (var i = 0; i < this.uploadData.length; i++) {
                    //alert(this.formData.commoditypiclist[i])
                    if (url===this.uploadData[i].url){
                        this.uploadData.splice(i, 1);
                        console.info("commoditypiclist9999999999"+JSON.stringify(this.formData.commoditypiclist))
                    }
                }

                console.info(this.uploadData)
            },
            //上传图片
            handleSuccess(response, file) {
                this.isSelect = false;
                console.log("上传成功");
                if (response.status === 1) {
                    const filePath = response.data;
                    this.formData.topcategorypic = filePath;
                    console.info(filePath + file);

                    return;
                }

                this.$message.error("上传文件报错");
            },
            handleChange(file) {
                this.fileName = file.name ? file.name : "";
                return false;
            },
            //筛选分类
            selectopcategory() {
                this.query.currentPage = 1;
                this.$router.push({
                    path: "",
                    query: this.query
                });
                this.getList();
            },
            /*隐藏 -新增或编辑弹框*/
            hideDialogAddOrEdit() {
                this.dialogAddOrEdit = false;

                //隐藏弹框时需要清除弹框内容
                if (this.$refs["ruleForm"]) {
                    this.$refs["ruleForm"].resetFields(); //清除formData表单
                    this.$refs["ruleForm"].clearValidate(); //清除表单验证
                }
                //如果上传文件，还需要清除文件列表
            },
            //获得分类
            merchantsCommodityList() {
                this.loading = true;
                this.query.userid=this.getListQuery.userid;
                merchantsCommodityList(this.query)
                    .then(response => {
                        if (response.code) {
                            this.$message.error(response.message);
                        }
                        console.log(response);
                        // this.getList();
                        this.list = response.data.list || [];
                        this.totalNumber = response.totalNumber || 0;
                        setTimeout(() => {
                            this.loading = false;
                        }, 0.3 * 1000);
                    })
                    .catch(() => {
                        this.loading = false;
                        this.list = [];
                        this.totalNumber = 0;
                    });
            },

            /*列表查询条件事件*/
            onSubmit() {
                this.merchantsCommodityList();
            },

            /*刷新*/
            onRest() {
                this.$router.push({
                    path: ""
                });
                this.getList();
            },

            //显示 查看弹框
            detailForm(row) {
                console.log(row);
                this.inputData=[]
                this.commodityDetails = row;
                this.formData = row;
                this.dialogAddOrEdit = true;

                //处理商品属性模板
                if (row.attributecontenct != null) {
                    this.attributecontenct = JSON.parse(row.attributecontenct);
                    this.formData.attributecontenct = JSON.parse( row.attributecontenct );
                    if ( this.attributecontenct != null && this.attributecontenct != undefined) {
                            this.attributecontenct .forEach((item) => {
                                this.formData1[item.fieldname] = item.fieldvalue;
                            });
                    }
                }
                if (row.attributeextendcontenct != null) { 
                    this.attributeextendcontenct = JSON.parse(row.attributeextendcontenct);
                    this.formData.attributeextendcontenct = JSON.parse(row.attributeextendcontenct);
                    if ( this.attributeextendcontenct != null && this.attributeextendcontenct != undefined) {
                            this.attributeextendcontenct.forEach((item) => {
                                this.formData1[item.extendfieldname] = item.fieldvalue;
                            });
                    }
                }
                if(row.certificationcontent!=null){
                    this.categoryTemplate = JSON.parse(row.certificationcontent);
                    this.formData.certificationcontent = JSON.parse(row.certificationcontent);
                    console.log(JSON.stringify(this.categoryTemplate))
                    if(this.categoryTemplate.templateItemFormList!=null&&this.categoryTemplate.templateItemFormList!=undefined){
                        this.categoryTemplate.templateItemFormList.forEach(item => {
                                this.formData4[item.fieldname] = item.fieldvalue;
                            }
                        );
                    }
                }
               if(row.inventorylist!=null&&row.inventorylist[0].inputdata!=null){
                    this.inputData= JSON.parse(row.inventorylist[0].inputdata);
                }else{
                    let data={
                        key:"",
                        val:""
                    }

                    this.inputData.push(data);
                }
                this.parameterlist=row.inventorylist;
                for(let i=0;i<this.parameterlist.length;i++){
                    let sav=[];
                    this.$set(this.parameterlist[i], "savparameterlist", sav);
                    this.$set(this.parameterlist[i], "splist", sav);

                    var a=this.parameterlist[i].inventory.indexOf("}");
                    var b=this.parameterlist[i].inventory.substring(1,a)
                    var a1=b.split(",");
                    var splist1=[];
                    for (let c=0;c<a1.length;c++) {
                        var s=a1[c].split(":")[1].substring(1,a1[c].split(":")[1].length-1);
                        splist1.push(s)
                    }
                    this.parameterlist[i].splist=(splist1);
                    this.parameterlist[i].savparameterlist=JSON.parse(this.parameterlist[i].secinventory);

                    this.parameterlist[i].companytype= this.parameterlist[i].companytype.toString();
                }
                //参数
                let sav=[];
                if(this.parameterlist!=null&&this.parameterlist.length>0){

                    for(let i=0;i<this.parameterlist.length;i++){
                        let pdata=JSON.parse(this.parameterlist[i].secinventory);

                        console.info(pdata)

                        for (let i=0;i<pdata.length;i++) {
                            let mdata=pdata[i]
                            for (let v in mdata){
                                let data={
                                    key:v,
                                    val:mdata[v].toString()
                                }
                                sav.push(mdata[v].toString());
                            }
                        }
                        this.parameterlist.savparameterlist=pdata;
                    }
                    this.parameterlist.splist=sav;
                }
            },

            /*点击页数*/
            handleCurrentChange(val) {
                this.query.currentPage = val;
                this.getList();
            },

            /*选择每页条数【10,20,30,40,50】*/
            handleSizeChange(val) {
                this.query.pageSize = val;
                this.getList();
            },
            goBack() {
                this.$emit("goBack");
            },
            examine(type) {
                if (type == 2) {
                    this.dialogFormVisible = true;
                    return false;
                }
                // 1 通过 2 驳回
                let data = {
                    commodityid: this.commodityDetails.commodityid,
                    commoditystatus: 1
                };
                this.merchantsCommodityToExamine(data);
            },
            reject() {
                if (!this.rejectreason) {
                    this.$message.error("请填写驳回原因！");
                    return false;
                }
                // 1 通过 2 驳回
                let data = {
                    commodityid: this.commodityDetails.commodityid,
                    commoditystatus: 2,
                    rejectreason: this.rejectreason
                };
                this.dialogFormVisible = false;
                this.merchantsCommodityToExamine(data);
            },
            merchantsCommodityToExamine(data) {
                merchantsCommodityToExamine(data)
                    .then(response => {
                        console.log(response);
                        if (response.code != 0) {
                            this.$message.error(response.message);
                            return false;
                        }
                        this.dialogAddOrEdit = false;
                        this.$message.success(response.message);
                        this.merchantsCommodityList();
                        setTimeout(() => {
                            this.loading = false;
                        }, 0.3 * 1000);
                    })
                    .catch(() => {
                        this.loading = false;
                    });
            }
        },
        created() {
            this.merchantsCommodityList();
        }
    };
</script>
<style lang="scss">
    .commodityDetails {
        border-top: 2px solid #ebeef5;
        .el-row:nth-first-child() {
            border-top: 1px solid #ebeef5;
        }
        .el-row {
            min-height: 60px;
            line-height: 60px;
            border-bottom: 1px solid #ebeef5;
        }
    }
    .commodityDetailsBox img {
        max-width: 100% !important;
        margin: auto;
        display: block;
        height: auto;
    }
    .el-upload--picture-card {
        background-color:unset;
        border:0px;
    }
</style>
